package edu.whut.jdk8.instruct;

import java.net.SocketTimeoutException;
import java.time.LocalDate;
import java.time.Period;

/*
Period工具类:年月日
 */
public class PeriodDemo {
    public static void main(String[] args) {
        LocalDate today = LocalDate.now();
        System.out.println(today);

        LocalDate otherDate = LocalDate.of(2023,5,5);
        System.out.println(otherDate);

        Period period = Period.between(otherDate,today);//第二个减第一个
        System.out.println(period.getYears());
        System.out.println(period.getMonths());
        System.out.println(period.getDays());
        System.out.println(period.toTotalMonths());//总月份
    }
}
